package com.wp.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wp.dao.DeptDao;
import com.wp.entity.Dept;
import com.wp.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: WangPeng
 * @createTime: 2022/11/17 15:55
 * @description:
 * @version: v1.0
 */
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptDao deptDao;
    @Override
    public PageInfo<Dept> getAllDept(int current, int pageSize) {
        PageHelper.startPage(current,pageSize);
        List<Dept> deptList = deptDao.selectAll();
        PageInfo<Dept> deptPageInfo = new PageInfo<>(deptList);
        return deptPageInfo;
    }

    @Override
    public int deleteById(int id) {
        return deptDao.delete(id);
    }

    @Override
    public int insertDept(Dept dept) {
        return deptDao.insert(dept);
    }

    @Override
    public int updateById(Dept dept) {
        return deptDao.update(dept);
    }
}
